
function checkPassword(flag){
		$("#pass-error").hide();
		$("#repass-error").hide();
		$("#pass-error").html("");
		$("#repass-error").html("");
		var psd = $("#indexPassword").val();
		if(!psd || psd.length<6){
		 	$("#pass-error").html("请填写密码且长度不能少于6个字符");
		 	$("#pass-error").show();
		 	return;
		}
		if(flag){return}
		var repsd = $("#indexRepassword").val();
		if(!repsd || repsd.length<6){
			$("#repass-error").html("请再次填写密码且长度不能少于6个字符");
		 	$("#repass-error").show();
		 	return;
		}
		if(psd != repsd){
			$("#repass-error").html("两次填写密码不一致，请重新填写");
		 	$("#repass-error").show();
		 	return;
		}
}
		
function restPassword(){
	checkPassword();
	if($("#pass-error").html()) return;
	if($("#repass-error").html()) return;
	$.ajax({
		url:"user/restPassword",
		type: "POST",
        dataType: "json",
        data:$("#restForm").serialize(),
		success:function(data){
			console.log(data);
			if(data.ret==200 && !data.content){
				myAlert("修改成功！");
			}else{
				if(data.ret==200){
					myAlert(data.content.msg);
				}else{
					myAlert(data.msg);
				}
				$("#my-alert").show();
			}
		},
		error:function(data){
		}  
	});
}
//<div class="am-modal am-modal-alert am-modal-out" tabindex="-1" id="my-alert" style="display: none;" id="alertDiv">
//<div class="am-modal-dialog">
//  <div class="am-modal-hd"  id="alertTitle">提示</div>
//  <div class="am-modal-bd" id="alertText">hello</div>
//  <div class="am-modal-footer">
//    <span class="am-modal-btn">确定</span>
//  </div>
//</div>
//</div>


function myAlert(text){
	$("#my-alert").attr("class", "am-modal am-modal-alert am-modal-active");
	$("#my-alert").css('display','block'); 
	$("#alertText").html(text);
}




